package com.afu.thread;

/**
 * ClassName: ThreadSecurityProblem
 * Package: com.afu.thread
 * Description:
 *
 * @Author zxf
 * @Create 2024/2/26 17:22
 * @Version 1.0
 */
public class ThreadSecurityProblem  implements  Runnable{
    private static int totalTicketNum = 100;
        private String name ;

    public ThreadSecurityProblem(String name) {
        this.name = name;
    }

    @Override
    public void run() {

        while (totalTicketNum > 0){
            try {
                Thread.sleep(20);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(name + "卖出了一张票，号码是：" + totalTicketNum);
            totalTicketNum--;
        }
    }
}
